package com.cskaoyan.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.stereotype.Component;

@Component
public class CustomAdvice implements MethodInterceptor {
    //代理对象执行对应方法的时候，就是执行到这个invoke方法
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        System.out.println("学姐好");
        Object proceed = methodInvocation.proceed();//method.invoke → 执行的是委托类的方法
        System.out.println("学姐再见");

        return proceed;//代理对象执行方法的返回值
    }
}
